# _*_ coding: utf-8 _*_

from Snap7.pySnap7 import Smart200

if __name__ == '__main__':
    # 连接PLC
    c = Smart200('192.168.3.180')

    ret = c.ConnectPLC()
    # c.CloseConnect()
    # 初始状态：全0，灯开阀门开
    # c.WriteData('VB', 7.0, 3)
    # 阀与泵关
    # c.WriteData('VB', 19.0, 1)
    # 远程灯亮
    # c.WriteData('VB', 7, 0)
    # c.WriteData('VB', 0, 1)
    # c.WriteData('VB', 2, 1)
    # c.WriteData('VB', 890, 1)
    c.WriteData('VB', 7, 0)
    c.WriteData('VB', 0, 0)
    c.WriteData('VB', 2, 0)
    c.WriteData('VB', 890, 0)
    c.WriteData('VB', 20.0, 0)
    c.CloseConnect()
    # c.WriteData('VB', 890.1, True)
    # F = c.ReadData('VB', 890.1)
    # F = F['data']
    # data1 = int(''.join(map(str, F)))
    # print(data1)
    # # c.WriteData('VB', 2, 0)
    # A = c.ReadData('VB',890)
    # print(A)
    # c.CloseConnect()

    # c.WriteData('V',  2, 1)
    # R = c.ReadData('V', 2)
    # print(R)
    # F = c.ReadData('V', 2.1)
    # print(F)
    # c.CloseConnect()
    # 阀开，泵没开
    # c.WriteData('VB', 19.0, 0)
    # # 发析晶信号 析晶灯亮
    # c.WriteData('VB', 20.0, 0)
    # 析晶灯灭
